package yapl.symbolChecker;

import yapl.interfaces.CompilerError;

public class SymbolException extends Exception implements CompilerError {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public int line;
	public int column;
	public int errorNumber;
	public boolean isProcedure;
	public SymbolException(int l,int c,int eN) {
		line=l;
		column=c;
		errorNumber=eN;
	}
	@Override
	public int errorNumber() {
		return errorNumber;
	}

	@Override
	public int line() {
		return line;
	}

	@Override
	public int column() {
		return column;
	}
	
	public String getMessage() {
		//System.out.println("YAPL Compilation: [<"+Main.programName+">] ERROR <"+errorNumber+"> (line <"+line+">, column <"+column+">)");
		if(errorNumber==10){
			return "identifier <"+Main.currentToken()+"> already declared in current scope (as <"+Main.lookup()+">)";
		}
		else if(errorNumber==11) {
			return "identifier <"+Main.currentToken()+"> not declared";
		}
		else if(errorNumber==12){
			return "illegal use of <"+Main.lookup()+"> <"+Main.currentToken()+">";
		}
		else if(errorNumber==13) {
			if(isProcedure) {
				isProcedure=false;
				return "End <"+Main.currentToken()+"> does not match Procedure <"+Main.lastProcedureName+">";
			}
			return "End <"+Main.currentToken()+"> does not match Program <"+Main.programName+">";
		}
		return "unidentified error";
		
	}

}